#include "Contour2.h"
#include "Point2.h"
#include "IoPoint2.h"
#include "IoVector2.h"
#include <iostream>
#include <iterator>
#include <algorithm>


namespace Tests {
	template<class T>
	std::ostream& operator << ( std::ostream& out, const std::vector<T>& container ) {
		out << '{';
		if ( !container.empty() ) {
			std::copy( container.begin(), --container.end(), std::ostream_iterator<T>( out, ", " ) );
			out << container.back();
		}
		out << '}';
		return out;
	}

	template<class T>
	std::ostream& operator << ( std::ostream& out, const Contour2_t<T>& poly ) {
		return out
			<< "Vertices: " << poly.vertices() << std::endl
			<< "Edge normals: " << poly.edgeNormals() << std::endl
			<< "Vertex normals: " << poly.vertexNormals() << std::endl;
	}

	void contour() {
		Point2 outline[] = {
			Point2( -1, -1 ),
			Point2(  1, -1 ),
			Point2(  1,  1 ),
			Point2( -1,  1 )
		};

		Point2 newOutline[] = {
			Point2( -2, 0 ),
			Point2( 2, -2 ),
			Point2( 2, 2 )
		};

		Contour2 poly = Contour2( outline, outline + sizeof(outline)/sizeof(outline[0]) );
		std::cout << poly << std::endl;

		{
			Contour2::VertexLock lock = poly.lockVertices();
			Contour2::point_array_type& vertices = lock.vertices();

			vertices.assign( newOutline, newOutline + sizeof(newOutline)/sizeof(newOutline[0]) );
		}

		std::cout << poly << std::endl;
	}
}